﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AnesSystem.Models;

namespace AnesSystem.ViewModels
{
    public class LaborRealTimeSignLeftCtrlViewModel : BaseViewModel<LaborRealTimeSignLeftCtrlViewModel>
    {
        #region Variables
        private ObservableCollection<ConfigVitalSignsModel> _vitalSigns;

        private int _selectedIndex;
        #endregion


        #region Constructor
        public LaborRealTimeSignLeftCtrlViewModel()
        {
            _vitalSigns = new ObservableCollection<ConfigVitalSignsModel>();
            InitData();
           
        }




        #endregion


        #region Properties
        public ObservableCollection<ConfigVitalSignsModel> VitalSigns
        {
            get
            {
                return _vitalSigns;
            }

            set
            {
                _vitalSigns = value;
            }
        }

        public int SelectedIndex
        {
            get
            {
                return _selectedIndex;
            }
            set
            {
                _selectedIndex = value;
                RaisePropertyChanged("SelectedIndex");
            }
        }


        #endregion


        #region 依赖属性


        #endregion


        #region Event


        #endregion


        #region PrivateMethods
        private void InitData()
        {
            Clear();
            foreach (var item in DataManager.Instance.CurrentPatientLink.VitalSignShow.LaborVitalSign)
            {
                VitalSigns.Add(item);
            }
        }
        private void Clear()
        {
            VitalSigns.Clear();
        }


        #endregion


        #region Public/ProtectedMethods

        public override void Refresh()
        {
            InitData();
        }

        public void AddConfigVitalSignName(ConfigVitalSignsModel configVitalSignsModel)
        {
            VitalSigns.Add(configVitalSignsModel);
        }
        #endregion
        public void RemoveConfigVitalSignName(ConfigVitalSignsModel configVitalSignsModel)
        {
            int index = -1;
            for (int i = 0; i < VitalSigns.Count; i++)
            {
                if (VitalSigns[i].code.Equals(configVitalSignsModel.code))
                {
                    index = i;
                }
            }
            if (index != -1)
            {
                VitalSigns.RemoveAt(index);
            }
        }

        #region EventHandlers


        #endregion
    }
}
